layui.use(['element', 'table', 'jquery'], function () {
    var table = layui.table;
    var $ = layui.jquery;
    var element = layui.element;
    //获取课程id
    var courseId = localStorage.getItem('journalCourseId');
    $.ajax({
        url: '/course/getCourseJournal',
        type: 'post',
        dataType: 'json',
        data: {'courseId': courseId,'type':2},
        success: function (data) {
            tablereload(data.data);
        }
    });

    function tablereload(data) {
        table.render({
            elem: '#table',
            data: data,
            title: '日志',
            page: {
                limit: 10,
                layout: ['count', 'prev', 'page', 'next', 'skip', 'refresh'],
                first: '首页',
                last: '尾页'
            },
            cols: [[
                {type: 'checkbox'},
                {field: 'courseId', title: '课程编号', align: 'center'},
                {field: 'courseName', title: '课程名称', align: 'center'},
                {
                    field: 'courseNprice', title: '课程价格', align: 'center', templet: function (data) {
                        return "<div><p>现价：￥" + data.courseNprice + "</p><p>原价：￥" + data.coursePrice + "</p></div>";
                    }
                },
                {
                    field: 'courseStatus', title: '上架/下架', align: 'center', templet: function (data) {
                        if (data.courseStatus == 2) {
                            return "上架";
                        } else {
                            return "未上架"
                        }
                    }
                },
                {
                    field: 'courseCstatus', title: '审核状态', align: 'center', templet: function (data) {
                        if (data.courseCstatus == 3) {
                            return "未审核";
                        } else if (data.courseCstatus == 4) {
                            return "审核通过";
                        } else {
                            return "审核失败";
                        }
                    }
                },
                {field: 'updateDate', title: '操作时间', align: 'center'},
            ]]
        });
    }

})
